import React from 'react';
import { useSelector, useDispatch, connect } from 'react-redux';

const Home = (props) => {
    console.log(props)
    const list = useSelector(state => state.homeData.list)
    // console.log(a)
    const dispatch = useDispatch();
    const add = () => {
        dispatch({ type: 'add_item', payload: 200 })
    }
    return (
        <div>
            Home<button onClick={add}>添加</button>
            <ul>
                {
                    list.map(item => <li>{item}</li>)
                }
            </ul>
        </div>
    )
}

//拿所有的list
const mapStateToProps = state => state.homeData
//只要一个list
// const mapStateToProps = state => ({ list: state.homeData.list })

// export default connect(state=>state.homeData)(Home)

export default connect(mapStateToProps)(Home)
